<template>
	<view class="main">
		<view class="level" v-for="(item,index) in levelList" v-if="cardData.tags==item.level">
			<image :src="item.img" mode="widthFix" :style="{width:`${tagWidth}rpx`}" lazy-load  :lazy-load-margin='0'	></image>
		</view>
		<!-- disabled -->
		<view class="content" :style="cardData.disabled?'opacity: 0.58':''">
			
		<view class="imgLay">

		<!-- 	<image v-if="cardData.thumbnail" :src="cardData.thumbnail|completeUrl" class="cardImg" mode="aspectFill"
				:style="{height:`${cardHeight}rpx`,width:`${cardWidth}rpx`}" lazy-load  :lazy-load-margin='0'	></image>
			<image v-else :src="(cardData.ActivityImg||cardData.image_url)|completeUrl" class="cardImg" mode="aspectFill"
				:style="{height:`${cardHeight}rpx`,width:`${cardWidth}rpx`}" lazy-load  :lazy-load-margin='0'	></image> -->
				<image :src="cardData[urlKey]|completeUrl" class="cardImg" mode="aspectFill"
				:style="{height:`${cardHeight}rpx`,width:`${cardWidth}rpx`}" lazy-load  :lazy-load-margin='0'	@click="imageClick(cardData)"></image>

			<slot name="option">
				<!-- 选择 -->
			</slot>
		</view>
		<view class="infoLay">

			<view class="title" :style="{color: `${titleColor}`,width:`${cardWidth}rpx`}">
				{{cardData.name||cardData.image_name}}
			</view>
			<slot name="infoMore">
				<!--  信息补充 -->
			</slot>
		</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "cardBag",
		props: {
			cardData: {
				type: Object,
				default: () => {
					return {}
				}
			},
			cardWidth: {
				type: Number,
				default: () => {
					return 208
				}
			},
			cardHeight: {
				type: Number,
				default: () => {
					return 208
				}
			},
			titleColor: {
				type: String,
				default: () => {
					return "#000000"
				}
			},
			tagWidth: {
				type: Number,
				default: () => {
					return 72
				}
			},
			urlKey: {
				type: String,
				default () {
					return 'ActivityImg'
				}
			},
		},
		data() {
			return {
				levelList: [{
					img: require('@/components/cardBag/img/xd.png'),
					level: 1
				}, {
					img: require('@/components/cardBag/img/jb.png'),
					level: 2
				}, {
					img: require('@/components/cardBag/img/xy.png'),
					level: 3
				}, {
					img: require('@/components/cardBag/img/yc.png'),
					level: 4
				}]
			};
		},
		methods:{
			imageClick(item){
				this.$emit('imgClick',item)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		background: #FFFFFF;
		box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(0, 0, 0, 0.18);
		border-radius: 20rpx;
		// @include flexLayout(center, center);
		// flex-direction: column;
		padding: 12upx;
		position: relative;

		.imgLay {
			position: relative;
			overflow: hidden;
			border-radius: 10upx;

			.cardImg {
				border-radius: 10upx;
				background-color: #F3F3F3;
			}
		}

		.title {
			font-family: SourceHanSansSC;
			font-weight: 500;
			font-size: 22rpx;
			color: #000000;
			line-height: 31rpx;
			overflow: hidden;
			position: relative;
			&::after{
				content: '';
				position: absolute;
				height: 30upx;
				width: 40upx;
				right: 0;
				background: linear-gradient( 90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 50%, rgba(255,255,255,1) 100%);
			}
		}

		.level {
			position: absolute;
			z-index: 9;
			top: -4upx;
			right: 0;

			image {

				width: 72rpx;
				height: 30rpx;
			}

			// box-shadow: 0rpx 2rpx 2rpx 0rpx rgba(0,0,0,0.23);


		}
	}
</style>